from utils import xprimes

MAX = 1000000
CONS = 4

primes = list(xprimes(MAX))
primeset = set(primes)

def factors(n):
    if n in primeset:
        return 1
    fn = 0
    for p in primes:
        if n % p == 0:
            fn += 1
            while ( n % p == 0):
                n /= p
            if n == 1:
                break
        if n in primeset:
            fn += 1
            break
    return fn

count = 0    
for n in xrange(2, MAX):
    if factors(n) == CONS:
        count += 1
    else:
        count = 0
    if count == CONS:
        print n - CONS + 1
        break

